home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-03-01 | 2.8 KB | 60 lines | [TEXT/KAHL] |
- //• SATStrictGridToolbox;
-
- // Routines for "strict" grid movement, like PacMan.
-
- // You need to make a copy of SATGridStubs.p, edit it as appropriate and include in
- // the same project. Also, SATStrictGridToolbox.p needs to be included, as source-code,
- // not as a library.
-
- #include <SAT.h>
- #include <SATToolbox.h>
- #include <SATGridToolbox.h>
-
- typedef struct {
- /* Variables that you should change as appropriate */
- short kind; /* Used for identification. >0: friend. <0 foe */
- Point position;
- Rect hotRect, hotRect2; /* Tells how large the sprite is; hotRect is centered around origo */
- /*hotRect is set by you. hotRect2 is offset to the current position.*/
- FacePtr face; /* Pointer to the Face (appearance) to be used. */
- ProcPtr task; /* Callback-routine, called once per frame. If task=nil, the sprite is removed. */
- ProcPtr hitTask; /* Callback in collisions. */
- ProcPtr destructTask; /* Called when a sprite is disposed. (Usually nil.) */
- RgnHandle clip; /*Clip region to be used when this sprite is drawn.*/
- /* SAT variables that you shouldn't change: */
- Point oldpos; /*Used by RunSAT2*/
- SpritePtr next, prev; /*You may change them in your own sorting routine, but be careful if you do.*/
- Rect r, oldr; /*Rectangle telling where to draw. Avoid messing with it.*/
- FacePtr oldFace; /*Used by RunSAT2*/
- Boolean dirty; /*Used by RunSAT2*/
- /*Variables for internal use by the sprites. Use as you please. Edit as necessary - this is merely a default*/
- /*set, enough space for most cases - but if you change the size of the record, call SetSpriteSize immediately*/
- /*after initializing (before any sprites are created)!*/
- short layer; /*For layer-sorting. When not used for that, use freely.*/
- Point gridPos; /* Position in grid coordinate. */
- short mode; /* Usually used for different modes and/or to determine what image to show next. */
- long whatever; /*free for any use*/
- SignedByte direction, partMove;
- short appInt; /*free for any use.*/
- } GridSprite, *GridSpritePtr;
-
- pascal void InitStrictGrid();
- pascal Boolean GridMoveSprite(GridSpritePtr theSprite, short howFar);
- pascal void GridTurnAroundSprite(GridSpritePtr theSprite);
- pascal void GridRectBounce(GridSpritePtr theSprite, GridSpritePtr anotherSprite, short push);
- pascal Boolean KeepInGrid(GridSpritePtr theSprite);
- pascal Boolean GridPtInGrid(Point p);
- pascal Boolean PossibleMove(GridSpritePtr sp, short direction);
- pascal Point GetGridStep(Point fromP, short direction, short distance);
-
- #define kUp 0
- #define kLeft 1
- #define kDown 2
- #define kRight 3
- #define kSnapDist 2
- /*How far from a junction can a sprite freely change direction if pushed?*/
-
- extern Point dirTable[4]; /*One step in each direction*/
- extern short sizeTable[4]; /*Size of grid spaces in each direction*/
-
-